// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import './style/reset.css'
import './style/main.css'
import 'element-ui/lib/theme-chalk/index.css'
import ElementUI from 'element-ui'
import pub from './script/pub.js'
Vue.prototype.$pub = pub

Vue.use(ElementUI)

Vue.config.productionTip = false

// router.beforeEach((to, from, next) => {
//   if (to.path === '/login') {
//     localStorage.removeItem('apptype')
//     localStorage.removeItem('appindex')
//     localStorage.removeItem('user')
//   }
//   let data = localStorage.getItem('user')
//   var dataObj = JSON.parse(data)
//   var timer = setInterval(
//     function () {
//       console.log('t')
//     }, 5000)
//   if (dataObj) {
//     if (new Date().getTime() - dataObj.time > 1140000) {
//       localStorage.removeItem('user')
//     }
//   }
//   if (!dataObj && to.path !== '/login') {
//     next({ path: '/login' })
//   } else {
//     next()
//   }
// })
router.beforeEach((to, from, next) => {
  if (to.path === '/') {
    next({ path: '/login' })
  } else {
    next()
  }
})

new Vue({
  el: '#app',
  router,
  // components: { App },
  // template: '<App/>'
  render: h => h(App)
}).$mount('#app')
